package com.forever7776.life.core.mapper.praise;

import com.forever7776.life.core.entity.praise.PraiseDetailBlog;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 博客点赞详细表 Mapper 接口
 * </p>
 *
 * @author kz
 * @since 2018-04-11
 */
public interface PraiseDetailBlogMapper extends BaseMapper<PraiseDetailBlog> {

    /**
     * 根据用户ID，博客ID查询一条数据
     *
     * @param userId
     * @param blogId
     * @return
     */
    PraiseDetailBlog selectOneByUserIdAndBlogId(@Param("userId") String userId, @Param("blogId") Integer blogId);

    /**
     * 修改博客点赞详细该条数据状态为：点赞
     *
     * @param userId
     * @param blogId
     * @return
     */
    @Update("update praise_detail_blog set status=0 where user_id=#{userId} and blog_id=#{blogId}")
    int updatePraiseBlogStatusPraise(@Param("userId") String userId, @Param("blogId") Integer blogId);

    /**
     * 修改博客点赞详细该条数据状态为：不点赞
     *
     * @param userId
     * @param blogId
     * @return
     */
    @Update("update praise_detail_blog set status=1 where user_id=#{userId} and blog_id=#{blogId}")
    int updatePraiseBlogStatusNotPraise(@Param("userId") String userId, @Param("blogId") Integer blogId);

}
